/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcalendar.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vcalendar.model.VFile;
import com.vportal.portlet.vcalendar.model.VFileModel;
import com.vportal.portlet.vcalendar.model.VFileSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VFile service. Represents a row in the &quot;VFile&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcalendar.model.VFileModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VFileImpl}.
 * </p>
 *
 * @author LongLH
 * @see VFileImpl
 * @see com.vportal.portlet.vcalendar.model.VFile
 * @see com.vportal.portlet.vcalendar.model.VFileModel
 * @generated
 */
@JSON(strict = true)
public class VFileModelImpl extends BaseModelImpl<VFile> implements VFileModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a v file model instance should use the {@link com.vportal.portlet.vcalendar.model.VFile} interface instead.
	 */
	public static final String TABLE_NAME = "VFile";
	public static final Object[][] TABLE_COLUMNS = {
			{ "fileId", Types.BIGINT },
			{ "fullname", Types.VARCHAR },
			{ "phone", Types.VARCHAR },
			{ "address", Types.VARCHAR },
			{ "birthday", Types.TIMESTAMP },
			{ "position", Types.VARCHAR },
			{ "status", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table VFile (fileId LONG not null primary key,fullname VARCHAR(200) null,phone VARCHAR(75) null,address VARCHAR(200) null,birthday DATE null,position VARCHAR(100) null,status LONG)";
	public static final String TABLE_SQL_DROP = "drop table VFile";
	public static final String ORDER_BY_JPQL = " ORDER BY vFile.fullname ASC";
	public static final String ORDER_BY_SQL = " ORDER BY VFile.fullname ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcalendar.model.VFile"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcalendar.model.VFile"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcalendar.model.VFile"),
			true);
	public static long STATUS_COLUMN_BITMASK = 1L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VFile toModel(VFileSoap soapModel) {
		VFile model = new VFileImpl();

		model.setFileId(soapModel.getFileId());
		model.setFullname(soapModel.getFullname());
		model.setPhone(soapModel.getPhone());
		model.setAddress(soapModel.getAddress());
		model.setBirthday(soapModel.getBirthday());
		model.setPosition(soapModel.getPosition());
		model.setStatus(soapModel.getStatus());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VFile> toModels(VFileSoap[] soapModels) {
		List<VFile> models = new ArrayList<VFile>(soapModels.length);

		for (VFileSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcalendar.model.VFile"));

	public VFileModelImpl() {
	}

	public long getPrimaryKey() {
		return _fileId;
	}

	public void setPrimaryKey(long primaryKey) {
		setFileId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_fileId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return VFile.class;
	}

	public String getModelClassName() {
		return VFile.class.getName();
	}

	@JSON
	public long getFileId() {
		return _fileId;
	}

	public void setFileId(long fileId) {
		_fileId = fileId;
	}

	@JSON
	public String getFullname() {
		if (_fullname == null) {
			return StringPool.BLANK;
		}
		else {
			return _fullname;
		}
	}

	public void setFullname(String fullname) {
		_columnBitmask = -1L;

		_fullname = fullname;
	}

	@JSON
	public String getPhone() {
		if (_phone == null) {
			return StringPool.BLANK;
		}
		else {
			return _phone;
		}
	}

	public void setPhone(String phone) {
		_phone = phone;
	}

	@JSON
	public String getAddress() {
		if (_address == null) {
			return StringPool.BLANK;
		}
		else {
			return _address;
		}
	}

	public void setAddress(String address) {
		_address = address;
	}

	@JSON
	public Date getBirthday() {
		return _birthday;
	}

	public void setBirthday(Date birthday) {
		_birthday = birthday;
	}

	@JSON
	public String getPosition() {
		if (_position == null) {
			return StringPool.BLANK;
		}
		else {
			return _position;
		}
	}

	public void setPosition(String position) {
		_position = position;
	}

	@JSON
	public long getStatus() {
		return _status;
	}

	public void setStatus(long status) {
		_columnBitmask |= STATUS_COLUMN_BITMASK;

		if (!_setOriginalStatus) {
			_setOriginalStatus = true;

			_originalStatus = _status;
		}

		_status = status;
	}

	public long getOriginalStatus() {
		return _originalStatus;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VFile toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VFile)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					VFile.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		VFileImpl vFileImpl = new VFileImpl();

		vFileImpl.setFileId(getFileId());
		vFileImpl.setFullname(getFullname());
		vFileImpl.setPhone(getPhone());
		vFileImpl.setAddress(getAddress());
		vFileImpl.setBirthday(getBirthday());
		vFileImpl.setPosition(getPosition());
		vFileImpl.setStatus(getStatus());

		vFileImpl.resetOriginalValues();

		return vFileImpl;
	}

	public int compareTo(VFile vFile) {
		int value = 0;

		value = getFullname().compareTo(vFile.getFullname());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VFile vFile = null;

		try {
			vFile = (VFile)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = vFile.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		VFileModelImpl vFileModelImpl = this;

		vFileModelImpl._originalStatus = vFileModelImpl._status;

		vFileModelImpl._setOriginalStatus = false;

		vFileModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VFile> toCacheModel() {
		VFileCacheModel vFileCacheModel = new VFileCacheModel();

		vFileCacheModel.fileId = getFileId();

		vFileCacheModel.fullname = getFullname();

		String fullname = vFileCacheModel.fullname;

		if ((fullname != null) && (fullname.length() == 0)) {
			vFileCacheModel.fullname = null;
		}

		vFileCacheModel.phone = getPhone();

		String phone = vFileCacheModel.phone;

		if ((phone != null) && (phone.length() == 0)) {
			vFileCacheModel.phone = null;
		}

		vFileCacheModel.address = getAddress();

		String address = vFileCacheModel.address;

		if ((address != null) && (address.length() == 0)) {
			vFileCacheModel.address = null;
		}

		Date birthday = getBirthday();

		if (birthday != null) {
			vFileCacheModel.birthday = birthday.getTime();
		}
		else {
			vFileCacheModel.birthday = Long.MIN_VALUE;
		}

		vFileCacheModel.position = getPosition();

		String position = vFileCacheModel.position;

		if ((position != null) && (position.length() == 0)) {
			vFileCacheModel.position = null;
		}

		vFileCacheModel.status = getStatus();

		return vFileCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{fileId=");
		sb.append(getFileId());
		sb.append(", fullname=");
		sb.append(getFullname());
		sb.append(", phone=");
		sb.append(getPhone());
		sb.append(", address=");
		sb.append(getAddress());
		sb.append(", birthday=");
		sb.append(getBirthday());
		sb.append(", position=");
		sb.append(getPosition());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcalendar.model.VFile");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>fileId</column-name><column-value><![CDATA[");
		sb.append(getFileId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>fullname</column-name><column-value><![CDATA[");
		sb.append(getFullname());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>phone</column-name><column-value><![CDATA[");
		sb.append(getPhone());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>address</column-name><column-value><![CDATA[");
		sb.append(getAddress());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>birthday</column-name><column-value><![CDATA[");
		sb.append(getBirthday());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>position</column-name><column-value><![CDATA[");
		sb.append(getPosition());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VFile.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VFile.class
		};
	private long _fileId;
	private String _fullname;
	private String _phone;
	private String _address;
	private Date _birthday;
	private String _position;
	private long _status;
	private long _originalStatus;
	private boolean _setOriginalStatus;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private VFile _escapedModelProxy;
}